package com.hospital.hospitalsystem.modules.admin.controller;

import com.hospital.hospitalsystem.base.BaseResponse;
import com.hospital.hospitalsystem.base.PageData;
import com.hospital.hospitalsystem.config.TokenVerify;
import com.hospital.hospitalsystem.modules.admin.biz.AdminBiz;
import com.hospital.hospitalsystem.modules.admin.dto.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author qiancheng@cqxyy.net
 * @date 2023/2/22
 */
@RestController
@RequestMapping("/admin")
@Api(tags = "管理员管理")
@Validated
public class AdminController {

    @Autowired
    private AdminBiz adminBiz;

    @ApiOperation(value = "查看申请医院列表")
    @RequestMapping(path = "/apply-list",method = RequestMethod.POST)
    @TokenVerify(type = "admin")
    public BaseResponse<PageData<HospitalRegisterRsp>> userRegister(@RequestBody ApplyListReq req){
        PageData<HospitalRegisterRsp> page = adminBiz.applyList(req);
        return BaseResponse.success(page);
    };

    @ApiOperation(value = "同意医院申请")
    @RequestMapping(path = "/approval-apply",method = RequestMethod.POST)
    @TokenVerify(type = "admin")
    public BaseResponse approvalApply(@RequestBody ApprovalApplyReq req){
        adminBiz.approvalApply(req);
        return BaseResponse.success();
    };

    @ApiOperation(value = "拒绝医院申请")
    @RequestMapping(path = "/refuse-apply",method = RequestMethod.DELETE)
    @TokenVerify(type = "admin")
    public BaseResponse reuseApply(@RequestBody ApprovalApplyReq req){
        adminBiz.reuseApply(req);
        return BaseResponse.success();
    };

    @ApiOperation(value = "新增药品介绍")
    @RequestMapping(path = "/medical-add",method = RequestMethod.POST)
    @TokenVerify(type = "admin")
    public BaseResponse medicalAdd(@RequestBody MedicalIntroduceReq req){
        adminBiz.medicalAdd(req);
        return BaseResponse.success();
    };

    @ApiOperation(value = "检查药品名称/批准文号介绍")
    @RequestMapping(path = "/medical-check",method = RequestMethod.POST)
    @TokenVerify(type = "admin")
    public BaseResponse medicalCheck(@RequestBody MedicalIntroduceReq req){
        MedicalIntroduceCheckRsp result = adminBiz.medicalCheck(req);
        return BaseResponse.success(result);
    };

    @ApiOperation(value = "删除药品介绍")
    @RequestMapping(path = "/medical-delete",method = RequestMethod.POST)
    @TokenVerify(type = "admin")
    public BaseResponse medicalDelete(@RequestBody MedicalIntroduceReq req){
        adminBiz.medicalDelete(req);
        return BaseResponse.success();
    };

    @ApiOperation(value = "获取药品列表")
    @RequestMapping(path = "/medical-get",method = RequestMethod.POST)
    @TokenVerify(type = "admin,user")
    public BaseResponse<PageData<MedicalIntroduceRsp>> medicalGet(@RequestBody MedicalIntroduceListReq req){
        PageData<MedicalIntroduceRsp> result = adminBiz.medicalGet(req);
        return BaseResponse.success(result);
    };

    @ApiOperation(value = "根据药品uuid获取信息")
    @RequestMapping(path = "/medical-get-one",method = RequestMethod.POST)
    @TokenVerify(type = "admin,user")
    public BaseResponse medicalGetOne(@RequestBody MedicalIntroduceReq req){
        MedicalIntroduceRsp result = adminBiz.medicalGetOne(req);
        return BaseResponse.success(result);
    };

    @ApiOperation(value = "修改药品列表")
    @RequestMapping(path = "/medical-update",method = RequestMethod.POST)
    @TokenVerify(type = "admin")
    public BaseResponse medicalUpdate(@RequestBody MedicalIntroduceReq req){
        adminBiz.medicalUpdate(req);
        return BaseResponse.success();
    };
}
